<?php

use Phinx\Db\Adapter\AdapterInterface;
use think\admin\extend\PhinxExtend;
use think\migration\Migrator;
use think\migration\db\Column;

class WechatLog extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        // 创建数据表对象
        $table = $this->table('wechat_log', [
            'engine' => 'InnoDB', 'collation' => 'utf8mb4_unicode_ci',
            'comment' => '微信日志',
        ]);
        // 创建或更新数据表
        PhinxExtend::upgrade($table, [
            ['url', AdapterInterface::PHINX_TYPE_TEXT, ['default' => null, 'null' => true, 'comment' => '请求地址']],
            ['method', 'string', ['default' => NULL, 'null' => true, 'comment' => '请求方式']],
            ['request', 'text', ['default' => NULL, 'null' => true, 'comment' => '请求参数']],
            ['response', 'text', ['default' => NULL, 'null' => true, 'comment' => '响应参数']],
            ['code', 'string', ['default' => NULL, 'null' => true, 'comment' => '响应码']],
            ['message', 'string', ['default' => NULL, 'null' => true, 'comment' => '响应信息']],
            ['ip', 'string', ['default' => NULL, 'null' => true, 'comment' => '请求IP']],
            ['uid', 'integer', ['default' => NULL, 'null' => true, 'comment' => 'UID']],
            ['time', 'integer', ['default' => NULL, 'null' => true, 'comment' => '耗时：毫秒']],
            ['create_at', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']],
            ['update_at', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']],
        ], [

        ], true);

    }
}
